# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Dict, Union
from fastapi import Query
from pydantic import BaseModel, Field


class NoticeSearchIn(BaseModel):
    """ 通知搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    client: int = Field(default=1, ge=1, le=2, description="接收端: [1=用户,2=平台]")
    name: Union[str, None] = Query(default=None, description="通知场景")


class NoticeDetailIn(BaseModel):
    """ 通知详情参数 """
    id: int = Field(gt=0, description="ID")


class NoticeListVo(BaseModel):
    """ 通知配置列表参数 """
    id: int = Field(description="ID")
    scene: int = Field(description="通知场景")
    name: str = Field(description="通知场景")
    type: str = Field(description="通知类型")
    sys_status: int = Field(ge=0, le=2, description="系统通知")
    ems_status: int = Field(ge=0, le=2, description="邮件通知")
    sms_status: int = Field(ge=0, le=2, description="短信通知")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "scene": 101,
                "name": "免密登录验证码",
                "type": "验证码",
                "sys_status": 2,
                "ems_status": 2,
                "sms_status": 1
            }
        }


class NoticeDetailVo(BaseModel):
    """ 通知配置详情参数 """
    id: int = Field(description="ID")
    scene: int = Field(description="通知场景")
    name: str = Field(description="通知场景")
    type: str = Field(description="通知类型")
    client: str = Field(description="接收端口")
    remarks: str = Field(description="场景描述")
    variable: dict = Field(description="场景描述")
    sys_template: Dict[str, str] = Field(default={}, description="系统通知")
    ems_template: Dict[str, str] = Field(default={}, description="邮件通知")
    sms_template: Dict[str, str] = Field(default={}, description="短信通知")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "scene": 101,
                "name": "免密登录验证码",
                "type": "验证码",
                "client": "用户端",
                "remarks": "用户手机号码登录时发送",
                "variable": {
                    "code": "验证码"
                },
                "sys_template": {},
                "ems_template": {},
                "sms_template": {
                    "status": "1",
                    "content": "${code}",
                    "template_code": "SMS_182535543"
                }
            }
        }
